<div class="wrapper">
	
	<!-- 用户填写的配送信息 -->
	<div class="panel panel-default address">
	
	<!-- 表单开始 -->
	<form action="<?php echo base_url('shopcar/success');?>" method="post" id="orderForm">
	
		<div class="form-group clearfix">
		
			<label><i>*</i>姓名</label>
			
			<div class="form-main">
				
				<input type="text" id="user_name" name="user_name" value="<?php echo $this->session->userdata('order_username');?>" placeholder="请输入收货人姓名" class="form-control" />
			
			</div>
			
		
		</div><!-- form-group -->

		<div class="form-group clearfix">
		
			<label><i>*</i>联系电话</label>
			<div class="form-main">
				<input type="text" id="phoneNumber" name="phoneNumber" value="<?php echo $this->session->userdata('order_phoneNumber');?>" placeholder="请输入手机号码" class="form-control" />
			</div>
		
		</div><!-- form-group -->
		
		<div class="form-group clearfix">
		
			<label><i>*</i>送货地址</label>
			
			<div class="form-main">
				
				<input type="text" id="address" name="address" value="<?php echo $this->session->userdata('order_address');?>" placeholder="例如：教五楼3楼&nbsp;/&nbsp;22栋宿舍楼" class="form-control" />
			
			</div>
			
		
		</div><!-- form-group -->
		
		<div class="form-group clearfix">
			<label>备注</label>
			
			<div class="form-main">
				
				<textarea type="text" name="remark" id="remark" class="form-control" placeholder="有什么话可以在这里写给快递小哥~"></textarea>
			
			</div>

		</div>
		
		<div class="form-group clearfix">
			<label>支付方式</label>
			
			<div class="form-main">
				
				<input type="radio" checked="checked" />货到付款
			
			</div>

		</div>
		
		<div class="form-group clearfix">
			<label>商品总计</label>
			
			<div class="form-main">
				
				<li>商品总计：<?php echo $total_price;?>元</li>
				<li>运费：0元</li>
				<li>合计：<span><?php echo $total_price;?>元</span></li>
			
			</div>

		</div>
		
		<div class="form-group clearfix">
			<label></label>
			
			<div class="form-main">
				
				<a href="Javascript:;" class="btn btn-danger" id="submitOrder">确认下单</a>
				<a href="<?php echo base_url();?>shopcar" class="btn btn-primary">返回购物车</a>
			
			</div>

		</div>
		
	</form>

	</div>

</div><!-- wrapper -->
<div id="whokdkdk"></div>
<script>
$("#submitOrder").click(function(){
	//姓名
	if($("#user_name").val()==''){
		alertError("填写一下姓名，要告诉我你是谁哦(⊙o⊙)");
		return false;
	}

	if($("#user_name").val().length > 50){
		alertError("收件人姓名不能超过50个字呦~");
		return false;
	}

	//手机号码
	if($("#phoneNumber").val()==''){
		alertError("联系电话需要填写一下，否则我找不到您呀╮(╯▽╰)╭");
		return false;
	}

	if(!$("#phoneNumber").val().match(/^1[3|4|5|7|8][0-9]\d{8}$/)){
		alertError("联系电话填错啦(⊙o⊙)…");
		return false;
	}

	//收货地址
	if($("#address").val()==''){
		alertError("收货地址不能为空哦~");
		return false;
	}

	if($("#address").val().length > 100){
		alertError("收货地址不能超过100个字吖( ⊙ o ⊙ )！");
		return false;
	}

	if($("#remark").val().length > 100){
		alertError("快递小哥只允许填写100个字的备注╭(╯^╰)╮");
		return false;
	}
	$.ajax({
		url:$("#baseUrl").val()+"shopcar/checkShopCar",
		dataType:"json",
		type:"post",
		success:function(e){

			if(e.status == '10601'){
				alertError('购物车还是空的，不能提交订单哦！');
			}else if(e.status=='10000'){
				$("#orderForm").submit();
			}else if(e.status=='10602'){
				alertError("“"+e.name+"”&nbsp;库存不足，请返回购物车修改购买数量");
			}
			
		}
		
	});

});
</script>

<!-- shopCarLogin -->
<div class="modal fade" id="shopCarLogin" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
        <h4 class="modal-title">用户登录</h4>
      </div>
      <div class="modal-body">
      	
      	<div class="form-group">
      		
      		<label>账号</label>
      		<input type="text" class="form-control" name="" />
      	
      	</div><!-- form-group -->
      	
      	<div class="form-group">
      		
      		<label>密码</label>
      		<input type="text" class="form-control" name="" />
      	
      	</div><!-- form-group -->
        
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-primary">登录</button>
      </div>
    </div>
  </div>
</div>

<!-- shopCarRegister -->
<div class="modal fade" id="shopCarRegister" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
        <h4 class="modal-title">用户注册</h4>
      </div>
      <div class="modal-body">
      
	      <div class="form-group">
	      		
	      		<label>账号</label>
	      		<input type="text" class="form-control" name="" />
	      	
	      	</div><!-- form-group -->
	      	
	      	<div class="form-group">
	      		
	      		<label>密码</label>
	      		<input type="text" class="form-control" name="" />
	      	
	      	</div><!-- form-group -->
	      	
	      	<div class="form-group">
	      		
	      		<label>确认密码</label>
	      		<input type="text" class="form-control" name="" />
	      	
	      	</div><!-- form-group -->
      	
        
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-primary">注册</button>
      </div>
    </div>
  </div>
</div>